package entity;

import service.CallService;
import service.SendService;

public  class TalkPackage extends ServicePackage implements CallService,SendService{
	private int talkTime;//通话时长
	private int smsCount;//短信条数
	public int getTalkTime() {
		return talkTime;
	}
	public void setTalkTime(int talkTime) {
		this.talkTime = talkTime;
	}
	public int getSmsCount() {
		return smsCount;
	}
	public void setSmsCount(int smsCount) {
		this.smsCount = smsCount;
	}
	@Override
	public void showInfo() {
		System.out.println("话唠套餐　： 通话："+talkTime+"分钟　  短信："+smsCount+"条　　资费"+price);
	}
	public TalkPackage(double price, int talkTime, int smsCount) {
		super(price);
		this.talkTime = talkTime;
		this.smsCount = smsCount;
	}
	public TalkPackage() {
		super();
		// TODO Auto-generated constructor stub
		this.talkTime = 300;
		this.smsCount = 50;
		this.price = 58.0;
	}
	public int call(int minCount, MobileCard card) {
		
		for (int i = 0; i < minCount; i++) {
			if(card.getRealTalkTime()<=this.talkTime) {
				card.setRealTalkTime(card.getRealTalkTime()+1);
			}else if(card.getRealTalkTime()>this.getTalkTime()) {
				
				card.setAonsumAmount(card.getAonsumAmount()-0.2);
			}
		}
		return 0;
	}
	public int send(int count, MobileCard card) {
		// TODO Auto-generated method stub
		for (int i = 0; i < count; i++) {
			if(card.getRealSMSCount()<=this.smsCount) {
				card.setRealSMSCount(card.getRealSMSCount()+1);
			}else if(card.getRealSMSCount()>this.getSmsCount()) {
				
				card.setAonsumAmount(card.getAonsumAmount()-0.5);
			}
		}
		return 0;
	}
}
